package com.ipc.app.web.controller.passager;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.ipc.app.biz.OrderBiz;
import com.ipc.app.constants.SessionConstants;
import com.ipc.app.model.Order;
import com.ipc.app.model.Paginator;

@Controller
@RequestMapping(value = "/jsp/passager/myOrder.do")
public class MyOrderAction {

	@Autowired
	private OrderBiz orderBiz;

	@RequestMapping(method = RequestMethod.GET)
	public String myOrderView(ModelMap model, HttpServletRequest request,
			String pageIndex) {
		String userID = (String) request.getSession().getAttribute(
				SessionConstants.LOGIN_USER_ID);

		if (null == pageIndex) {
			pageIndex = "1";
		}
		Paginator<Order> orders = orderBiz.getUserOrder(userID, Integer
				.valueOf(pageIndex));
		model.addAttribute("orders", orders);
		return "passager/myOrders";
	}
}
